package com.hotline.communication.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 外呼请求类型枚举类类
 * </p>
 *
 * @author yeshengqi
 * @since 2023-07-22 17:15
 */
public enum DialRequestTypeEnum {

    GET_CALL_PHONE(0,"获取主被叫"),
    START_CALL(1,"开始呼叫"),
    END_CALL(2,"呼叫结束");

    /**
     * 编码
     */
    private Integer code;

    /**
     * 名称
     */
    private String name;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    DialRequestTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static DialRequestTypeEnum getDialRequestTypeEnum(Integer code){
        for (DialRequestTypeEnum dialRequestTypeEnum : DialRequestTypeEnum.values()){
            if(dialRequestTypeEnum.getCode().equals(code)){
                return dialRequestTypeEnum;
            }
        }
        return null;
    }

    public static List getDialRequestTypeEnumList(){
        List list = new ArrayList();
        for (DialRequestTypeEnum dialRequestTypeEnum : DialRequestTypeEnum.values()){
            Map map = new HashMap<>();
            map.put("code",dialRequestTypeEnum.getCode());
            map.put("name",dialRequestTypeEnum.getName());
            list.add(map);
        }
        return list;
    }
}
